package com.mocoop.jfqc;

import android.os.Bundle;


import com.mocoop.activity.MocoopActivity;
import com.mocoop.activity.MocoopTabHostMultitionActivity;
import com.mocoop.commom.MyConstants;
import com.mocoop.commom.MyOSS;
import com.mocoop.entity.PageInfoEntity;
import com.mocoop.jfqc.JFQCActivity.BaseActivity;
import com.mocoop.task.AutoRequestTask;

public final class TabHostMultitionActivity extends MocoopTabHostMultitionActivity implements BaseActivity{

	private boolean firstShow = true;
	public JFQCActivity baseActivity;
	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		MyOSS.Init(this, getUserID());

		baseActivity = new JFQCActivity(this);
		changeCurrentWebView(baseActivity.getLaunchPage());
//		baseActivity.showLaunchView();
		
	}

	@Override
	public void changeItemListener(int id) {
		
		changeCurrentWebView(baseActivity.changeItemListener(id));
	}

	@Override
	public void showMeRightNow() {
		runOnUiThread(new Runnable() {
			@Override
			public void run() {
				if(firstShow){
					currentFragment.getCordovaWebView().loadUrl("javascript:");
					firstShow = false;
				}
				currentFragment.hideTitleStatus();
				TabHostMultitionActivity.super.showMeRightNow();
			}
		});
	}

	@Override
	public void jumpNewPage(PageInfoEntity pageInfoEntity) {
		runOnUiThread(new Runnable() {

			@Override
			public void run() {
				currentFragment.showTitleStatus();
			}
		});
		super.jumpNewPage(pageInfoEntity);

	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	public void netListener(int netStatus) {
		super.netListener(netStatus);
		if (netStatus == WIFI_NET) {
			new AutoRequestTask(this).execute(new String[] {getUserID()});
		}
	}

	@Override
	public void messageCountController( String tabName,  String msg) {
		baseActivity.messageCountController(tabName, msg);
	}

	@Override
	public JFQCActivity getJFQCActivity() {
		return baseActivity;
	}
	
	@Override
	protected void onStart() {
		super.onStart();
		baseActivity.onStart();
	}
	
	@Override
	protected void onStop() {
		super.onStop();
		baseActivity.onStop();
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		baseActivity.onDestroy();
	}
}
